package adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.IndexBean;
import student.andlei.com.student.R;


public class AllWorkAdapter extends BaseQuickAdapter<IndexBean.Task, BaseViewHolder> {
    private Context context;

    public AllWorkAdapter(Context context, int layoutResId, @Nullable List data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, IndexBean.Task item) {


        helper.setText(R.id.tv_subject, item.subject_name);
        helper.setText(R.id.tv_nofinish, "未完成：" + item.unfinished + "份");
        ImageView imageView = helper.getView(R.id.img_subject);
        //-----------------------科目分类 配色-------------------------------------------
        if (item.subject_name.equals("语文")) {
            imageView.setImageResource(R.mipmap.yuwen);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.yuwen);
        } else if (item.subject_name.equals("数学")) {
            imageView.setImageResource(R.mipmap.shuxue);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.shuxue);
        } else if (item.subject_name.equals("英语")) {
            imageView.setImageResource(R.mipmap.waiyu);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.waiyu);
        } else if (item.subject_name.equals("物理")) {
            imageView.setImageResource(R.mipmap.wuli);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.wuli);
        } else if (item.subject_name.equals("化学")) {
            imageView.setImageResource(R.mipmap.huaxue);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.huaxue);
        } else if (item.subject_name.equals("生物")) {
            imageView.setImageResource(R.mipmap.shengwu);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.shengwu);
        } else if (item.subject_name.equals("地理")) {
            imageView.setImageResource(R.mipmap.dili);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.dili);
        } else if (item.subject_name.equals("历史")) {
            imageView.setImageResource(R.mipmap.lishi);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.lishi);
        } else if (item.subject_name.equals("政治")) {
            imageView.setImageResource(R.mipmap.zhegnzhi);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.zhengzhi);
        } else if (item.subject_name.equals("技术")) {
            imageView.setImageResource(R.mipmap.jishu);
            helper.getView(R.id.layout_bg).setBackgroundResource(R.color.jishu);
        }


//
//        if (!StringUtils.isNull(item.subject_image)) {
//            //String img = item.subject_image.replace("\\","");
//            GlideUtils.loadImageView(context, item.subject_image, (ImageView) helper.getView(R.id.img_subject));
//        }
    }


}
